package com.loren.demo20.controller;

import com.loren.demo20.entity.User;
import com.loren.demo20.form.UserForm;
import com.loren.demo20.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping("/{id}")
    public User userInfo(@PathVariable("id") Long id) {
        return this.userService.getUserInfo(id);
    }

    @PostMapping
    public String addUserInfo(@RequestBody UserForm form) {
        this.userService.saveUserInfo(form);
        return "success";
    }

}
